﻿using Common;


using Frontdatabase;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Model;
using Model.UserModel;
using System.IdentityModel.Tokens.Jwt;
using WebFront.Service;

namespace WebFront.Controllers
{
    [ApiController,Route("api/[controller]/[action]"),Authorize]
    /// <summary>
    /// 用户对外相关接口类
    /// </summary>
    public class UserController
        (IUserSevice userSevice,JwtHelper _jwtHelper)
        :ControllerBase
    {
        [HttpPost,
            AllowAnonymous]
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns></returns>
        public async Task<ActionResult<ResResult>> Login([FromForm]UserLoginModel _userLoginModel)
        {
            if(!_userLoginModel.IsVerify) { return BadRequest("用户表单验证错误"); }

            return
                await userSevice.Login(_userLoginModel)
                ;
        }
                                    
         
    
    }
}
